cmake_minimum_required(VERSION 3.6.0)

if (NOT ROOT_DIR)
    set(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../")
endif()
set(CURRENT_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/toolchain_common.cmake)
#${PRODUCT_ROOT_DIR}/buildtools/cmake
message("ROOT_DIR: ${ROOT_DIR}, ${CMAKE_CURRENT_LIST_DIR}")
include(${CURRENT_CMAKE_PATH})

# set the other flags
set(CMAKE_C_STANDARD_LIBRARIES_INIT "-lm")
set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "-lm")
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

add_definitions(-DUSE_HTNICE)

if (NOT COMPILER_ROOT)
    set(COMPILER_ROOT ${ROOT_DIR}/buildtools/toolchains/gcc-gt675x-10.4.0-2023.06.27-x86_64_aarch64-htnice-linux-gnu)
endif()

set(CMAKE_SYSROOT "${COMPILER_ROOT}/usr/aarch64-htnice-linux-gnu/sysroot")
set(CMAKE_C_COMPILER "${COMPILER_ROOT}/bin/aarch64-htnice-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "${COMPILER_ROOT}/bin/aarch64-htnice-linux-gnu-g++")
set(CMAKE_AR           "${COMPILER_ROOT}/bin/aarch64-htnice-linux-gnu-ar")
set(CMAKE_RANLIB       "${COMPILER_ROOT}/bin/aarch64-htnice-linux-gnu-ranlib")
set(CMAKE_STRIP        "${COMPILER_ROOT}/bin/aarch64-htnice-linux-gnu-strip")
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_CROSSCOMPILING "TRUE")
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})

message(INFO " C compiler is ${CMAKE_C_COMPILER}")
message(INFO " CXX compiler is ${CMAKE_CXX_COMPILER}")

# add_definitions(-DSTDC_HEADERS
#   -DHAVE_LIMITS_H
#   -DHAVE_DECL_ISNAN
#   -DHAVE_DECL_ISINF
#   -DHAVE_DECL_INFINITY
#   -DHAVE_DECL_NAN
#   -DHAVE_SNPRINTF
#   -DHAVE_STDARG_H
#   -DHAVE_VASPRINTF
#   -DHAVE_STRDUP)